package com.ruoyi.datastatistics.Agreement;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Service
public class GuoXinV1 {

    @Resource
    private Environment env;


    public static void main(String[] args) {
//       String data = "C0411643091017370401000000000000000001130003000000012801004E79E0605B01000A91CD13330000E90200980000F702C9021500C49F5601FFFFFFFF000000000221485D00000000000000000000485D0000485D0000000000000000000000000000000311000000000000000000000000000000000009980070E0603C004842000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A7D0";
       // String data = "D37EFF60";
//        byte[] bit = hexStringToByteArray(data);
        //System.out.println(getTimeVFromByte(bit))
//        System.out.println(bytesToHexString(getValveControlData("185240625001","2")));
        /*try {
            System.out.println(getDateFromString("2402010000",0));
        } catch (ParseException e) {
            e.printStackTrace();
        }*/
        //byte[] valveControlData = getValveControlData("109230700049", "2");
        //System.out.println(convertToString(valveControlData));
        byte[] valveControlData = GuoXinV1.setBaseNumber("124564.56","109230700049");
        String payload = GuoXinV1.bytesToHexString(valveControlData);
        System.out.println(payload);
    }
    public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }
    /**
     * 解析日冻结数据
     * @param bit
     * @return
     */
    public static JSONObject GetBufferPacketForAll(byte[] bit)
    {

        JSONObject jo = new JSONObject();
        byte[] type = { 0x04 };
        boolean flag = getCsForAllType(bit, 8, type);
        if (flag)
        {
            try
            {
                jo = getDSDateinfoFromByte(bit);
                //jo = getDSDateinfoFromByte(bit);
            }
            catch (Exception e)
            {
                return null;
            }
            return jo;
        }
        else
        {
            return null;
        }

    }
    public static String convertToString(byte[] hexArray) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < hexArray.length; i++) {
            String temp = Integer.toHexString(hexArray[i] & 0xFF);
            temp = temp.length()<2? "0"+temp : temp;
            sb.append(temp);
        }
        return sb.toString();
    }

    /**
     * 阀控命令-发送
     * @param communicateAddress
     * @param isOpen 1开阀 2关阀
     * @return
     */
    public static byte[] getValveControlData(String communicateAddress,String isOpen){
        byte[] bit = new byte[30];
        bit[0] = (byte)0xC0;//起始符
        bit[1] = (byte)0x47;//类型码
        byte[] add = new byte[6];
        add = getByte(communicateAddress);
        System.arraycopy(add, 0, bit, 2, 6);
        bit[8] = 0x03;
        bit[9] = 0x01;
        bit[10] = 0x00;
        bit[16] = 0x07;
//        bit[16] = 0x01;
        bit[17] = 0x09;
        bit[19] = 0x13;
        bit[21] = 0x10;
        bit[22] = 0x30;
        bit[24] = 0x02;

        if(isOpen.equals("1")){
            //开阀
            bit[26] = 0x01;

        }else if(isOpen.equals("2")){
            //关阀
            bit[26] = 0x02;
        }
        //System.arraycopy(bit, 26, bit, 28, 2);

        byte[] temp1 = new byte[bit.length - 3];
        System.arraycopy(bit, 1, temp1, 0, temp1.length);
        bit[28] = getTotalForByte(temp1);
        bit[29] = (byte)0xD0;//类型码
        return bit;
    }

    /***
     * 阀控返回
     * @param bit
     * @return
     */
    public static JSONObject getValveControlReslut(byte[] bit){
        JSONObject jo = new JSONObject();
        byte[] bit_add = new byte[6];
        System.arraycopy(bit, 2, bit_add, 0, 6);
        String temp = getIntFromByte2(bit_add);//终端地址
        jo.put("communicateAddress",temp);
        if(bit[22] == 0x30 &&  bit[24] == 0x02){
            jo.put("status","OK");
        }
        return jo;

    }
    /**
     * 日冻结解析主程序
     * @param bit
     * @return
     */
    public static JSONObject getDSDateinfoFromByte(byte[] bit)
    {
        JSONObject jo = new JSONObject();
        try
        {
            String s_time_t = "";
           // String str = BitConverter.ToString(bit);
            if (bit.length > 21)
            {
                byte[] bit_add = new byte[6];
                System.arraycopy(bit, 2, bit_add, 0, 6);
                String temp = getIntFromByte2(bit_add);//终端地址
                jo.put("add", temp);
                jo.put("type", 3);
                jo.put("type_msg", "NB小表国信");//终端类型


                Integer index_num = 25;//存储第一组组数的起始位置 添加6bit的当前时间、5B每组时间、1B的密度

                JSONArray json_temp = new JSONArray();
                byte[] TotalFlowZero = new byte[4];
                while (index_num < bit.length - 2)
                {
                    byte bit_total_c = bit[index_num] ;//第一组tag

                    switch (bit_total_c)
                    {
                        case 0x01:
                            //走tag01逻辑
                            int tag_length = (int) bit[index_num + 1];
                            //终端电池电压

                            byte[] temp_voltage = new byte[1];
                            System.arraycopy(bit, index_num + 8, temp_voltage, 0, temp_voltage.length);
                            jo.put("voltage", getPressureVFromByte(temp_voltage));
                            //f阀控 状态1
                            byte status = bit[index_num + 9];
                            jo.put("valveStatus", getValveStatus(status));

                            jo.put("signal1", bit[index_num + 28]);
                            //信号
                            jo.put("signal1", bit[index_num + 28]);
                            //时间
                            byte[] temp_time = new byte[4];
                            System.arraycopy(bit, index_num + 4, temp_time, 0, temp_time.length);
                            s_time_t = getTimeVFromByte(temp_time);
                            jo.put("detailsTime", s_time_t);
                            jo.put("date", s_time_t.substring(0,6));//终端类型
                            //jo.Add("signal", getSignalFromByte(bit[bit.Length - bit_length + 1]));
                            index_num = 2 + tag_length+ index_num;
                            break;
                        case 0x02:
                            //走tag02逻辑
                            tag_length = bit[index_num + 1];
                            //累计流量

                            byte[] TotalFlow = new byte[4];
                            System.arraycopy(bit, index_num + 2, TotalFlow, 0, TotalFlow.length);
                            jo.put("TotalFlow", (float)getIntFromByte16(TotalFlow)/1000);

                            //日结算累计流量

                            System.arraycopy(bit, index_num + 2+12, TotalFlowZero, 0, TotalFlowZero.length);
                            jo.put("TotalFlowZero", (float)getIntFromByte16(TotalFlowZero)/1000);
                            //正流量

                            byte[] ReadNumber = new byte[4];
                            System.arraycopy(bit, index_num + 18, ReadNumber, 0, ReadNumber.length);
                            jo.put("ReadNumber", (float)getIntFromByte16(ReadNumber)/1000);
                            //反流量

                            byte[] ReverseNumber = new byte[4];
                            System.arraycopy(bit, index_num + 22, ReverseNumber, 0, ReverseNumber.length);
                            jo.put("ReverseNumber", (float)getIntFromByte16(ReverseNumber)/1000);

                            index_num = index_num + 2 + tag_length;
                            break;
                       /* case 0x09:
                            //最后记录时间
                            JSONObject joc_ = new JSONObject();
                            tag_length = 152;
                            int  num_t = bit[index_num + 8];

                            temp_time = new byte[4];
                            System.arraycopy(bit, index_num + 2, temp_time, 0, temp_time.length);
                            String s_time_t1 = getTimeVFromByte(temp_time);


                            joc_.put("time", getDateFromString(s_time_t1,num_t));

                            //间隔
                            joc_.put("density", bit[index_num +6]);//密度
                            //个数
                            joc_.put("num", num_t+1);

                            //截断num_t 个数据bit
                            byte[] info_ds = new byte[2 * num_t];
                            System.arraycopy(bit, index_num + 10, info_ds, 0, info_ds.length);

                            getDSDateinfoFromByteForTag09(info_ds, joc_, num_t, (double) getIntFromByte16(TotalFlowZero)/1000,getDateFromZero(s_time_t1),s_time_t1);
                            json_temp.add(joc_);
                            index_num = index_num + 2 + tag_length;
                            break;*/
                        case 0x11:
                            //走tag01逻辑
                            JSONObject joc = new JSONObject();
                            // tag_length = bit[index_num + 1];
                            //起始时间

                            byte[] bit_date_s = new byte[4];
                            System.arraycopy(bit, index_num +3, bit_date_s, 0, bit_date_s.length);
                            String s_t = getStringFromByte(bit_date_s);
                            joc.put("time", s_t);
                            jo.put("date", s_t.substring(0, s_t.length()-2));
                            //间隔
                            joc.put("density", bit[index_num +7]);//密度
                            //个数
                            int num_t = bit[index_num + 8];
                            joc.put("num", num_t);

                            byte[] info_ds = new byte[8 * num_t];
                            System.arraycopy(bit, index_num + 11, info_ds, 0, info_ds.length);

                            getDSDateinfoFromByte(info_ds, joc, 8, bit[13]);
                            json_temp.add(joc);
                            //jo.Add("signal", getSignalFromByte(bit[bit.Length - bit_length + 1]));
                            index_num = index_num + 3 + 8 * num_t;
                            break;
                        default:
                            tag_length = bit[index_num + 1];
                            //index_num = index_num + 2 + tag_length;
                            int temp_ = index_num + 2 + tag_length;
                            if(temp_>index_num){
                                index_num = temp_;
                            }else {
                                index_num =bit.length - 2;
                            }

                    }
                }
                if (json_temp.size() >= 0 )
                {
                    JSONArray json_joc_2 = new JSONArray();
                    JSONArray json_joc_3 = new JSONArray();
                    JSONObject joc_2 = new JSONObject();
                    try
                    {

                        joc_2.put("TotalFlow",jo.getString("TotalFlow"));//累计向流量
                        joc_2.put("ReadNumber", jo.getString("ReadNumber"));//正向流量
                        joc_2.put("ReverseNumber", jo.getString("ReverseNumber"));//反向流量
                        joc_2.put("detailsTime", s_time_t);//反向流量
                        json_joc_2.add(joc_2);
                        JSONObject joc = new JSONObject();

                        joc.put("time", s_time_t);
                        joc.put("num", 1);
                        joc.put("dsinfo", json_joc_2);
                        //json_joc_3.Add(joc);
                        json_temp.add(joc);
                    }
                    catch (Exception e)
                    {

                    }
                }
                jo.put("info", json_temp);

            }

        }
        catch (Exception e)
        {

        }
        return jo;
    }
    private static JSONObject getDSDateinfoFromByte(byte[] bit, JSONObject joc, int total, byte type)
    {

        try
        {
            JSONArray json = new JSONArray();
            Integer num = 8;
            for (int j = 0; j < total; j++)
            {
                byte[] temp_dsinfo = new byte[num];//表正向流量、反向流量、累计流量、瞬时流速+压力+验证
                System.arraycopy(bit, j * num, temp_dsinfo, 0, num);
                JSONObject joc_2 = new JSONObject();
                try
                {
                    byte[] temp = new byte[4];//时间，下面都偏移3b

                    System.arraycopy(temp_dsinfo, 0, temp, 0, temp.length);
                    int v = getIntFromByte16(temp);
                    joc_2.put("TotalFlow", v);//累计向流量

                    temp = new byte[4];
                    System.arraycopy(temp_dsinfo, 4, temp, 0, temp.length);
                    int v2 = getIntFromByte16(temp);
                    joc_2.put("ReadNumber", v2);//正向流量

                    joc_2.put("ReverseNumber", v2-v);//反向流量
                    json.add(joc_2);
                }
                catch (Exception e)
                {

                }
            }
            joc.put("dsinfo", json);
        }
        catch (Exception e)
        {

        }
        return joc;
    }

    /**
     * 最后记录读数时间 14:00，需要找到零点的用量
     * @param bit
     * @param joc
     * @param total
     * @param TotalFlowZero
     * @param dateFromZero
     * @return
     */
    private static JSONObject getDSDateinfoFromByteForTag09(byte[] bit, JSONObject joc, int total, double TotalFlowZero,Integer dateFromZero,String s_time_t)
    {

        try
        {
            JSONArray json = new JSONArray();
            double[] d = new double[total];
            double[] b = new double[ total + 1 ];
            Integer num = 2;
            for (int j = 0; j < total; j++)
            {
                try
                {
                    byte[] temp = new byte[2];//时间，下面都偏移3b

                    System.arraycopy(bit, j*num, temp, 0, temp.length);
                    double v = getIntFromByte16(temp)/1000;

                    d[j] = v;
                }
                catch (Exception e)
                {

                }
            }
            for(int j = 0; j < total+1; j++){
                if(j<=dateFromZero){

                    Double temp_p = TotalFlowZero;
                    Integer k = dateFromZero - j;
                    int p = 0;
                    while (p < k){
                        temp_p = temp_p + d[j+p];
                        p++;
                    }
                    b[j] = temp_p;
                }else{
                    Double temp_p = TotalFlowZero;
                    Integer k =  j - dateFromZero;
                    int p = 0;
                    while (p < k && j+p<d.length){
                        temp_p = temp_p - d[j+p];
                        p++;
                    }
                    b[j] = temp_p;
                  //  System.out.println("---------------"+j);
                }
            }
            for(int j = 0; j < total+1; j++){
                JSONObject joc_2 = new JSONObject();
                joc_2.put("TotalFlow", b[total-j]);//累计向流量

                joc_2.put("ReadNumber", b[total-j]);//正向流量

                joc_2.put("ReverseNumber", 0);//反向流量
                joc_2.put("detailsTime", s_time_t);//反向流量
                json.add(joc_2);
            }
            joc.put("dsinfo", json);
        }
        catch (Exception e)
        {

        }
        return joc;
    }

    /**
     * 解析 阀控 状态
     * @param bit
     * @return
     */
    public static String getValveStatus(byte bit){
        String flag = "3";
        String binaryString = getBinaryStrFromByte(bit);
        binaryString = binaryString.substring(6,8);
        if(binaryString.equals("01")){
            flag = "1";
        }else if(binaryString.equals("10")){
            flag = "0";
        }
        return flag;
    }
    /**
     * 把byte转化成2进制字符串
     * @param b
     * @return
     */
    public static String getBinaryStrFromByte(byte b){
        String result ="";
        byte a = b; ;
        for (int i = 0; i < 8; i++){
            byte c=a;
            a=(byte)(a>>1);//每移一位如同将10进制数除以2并去掉余数。
            a=(byte)(a<<1);
            if(a==c){
                result="0"+result;
            }else{
                result="1"+result;
            }
            a=(byte)(a>>1);
        }
        return result;
    }
    /**
     * bcd码,示例：109230700049-》0x10 0x92 0x30 0x70 ·······
     * @param ad
     * @return
     */
    public static byte[] getByte(String ad)
    {
        byte[] bit = new byte[6];
        int length = ad.length();
        for (int i = 0; i < 6; i++)
        {
            String temp = ad.substring(i * 2, i * 2+2);
            bit[i] = (byte)Integer.parseInt(temp,16);
        }
        return bit;
    }

    /**
     * 验证
     * @param bit
     * @param index
     * @param type
     * @return
     */
    public static boolean getCsForAllType(byte[] bit, int index, byte[] type)
    {
        boolean flag = true;
        if (bit != null & bit.length > 0)
        {
            String l1 = Integer.toHexString(bit[18]& 0xFF);
            String l2 = Integer.toHexString(bit[17] & 0xFF);
            l1 = l1 + (l2.length() < 2 ? ("0" + l2) : l2);
            int  recvlen = Integer.parseInt(l1,16);
            if (type.length > 0)
            {
                boolean temp = false;
                for (int i = 0; i < type.length; i++)
                {
                    if (bit[index] == type[i])
                    {
                        temp = true;
                        break;
                    }
                }
                flag = temp;
            }
            if (flag)
            {
                if (bit.length <= 0)
                {
                    flag = false;
                }
                else if (bit[0] != (byte)0xc0)
                {
                    flag = false;
                }
                else if (bit[9] != (byte)0x01)
                {
                    flag = false;
                }
                else if (recvlen != bit.length-21)
                {
                    flag = false;
                }
                else if (bit[(bit.length - 1)] !=  (byte)0xD0)
                {
                    flag = false;
                }
                else
                {
                    byte[] temp1 = new byte[bit.length - 3];
                    System.arraycopy(bit, 1, temp1, 0, temp1.length);
                    byte temp = getTotalForByte(temp1);
                    if (temp != bit[(bit.length - 2)])
                    {
                        flag = false;
                    }
                }
            }

        }

        return flag;
    }
    /**
     * 验证和
     * @param bit
     * @return
     */
    private static byte getTotalForByte(byte[] bit)
    {
        int sum = 0;
        if (bit.length > 0)
        {
            for (int i = 0; i < bit.length; i++)
            {
                sum = sum + bit[i];
                sum = sum & 0xFF;
            }
        }
        byte rein = (byte)sum;
        return rein;
    }

    /**
     * 压力解析
     * @param bit
     * @return
     */
    public static String getPressureVFromByte(byte[] bit)
    {
        String str = "";
        if (bit.length == 1)
        {
            int p = bit[0];
            str = (double)p*0.04 +"";
        }
        return str;
    }

    /**
     * 两位不足 补零,高位在hou,eg->0x0c 0x02:0c02
     * @param bit
     * @return
     */
    public static String getIntFromByte2(byte[] bit)
    {
        String str = "";
        for (int i = 0; i < bit.length; i++)
        {
            String temp = Integer.toHexString(bit[i]& 0xFF);
            temp = temp.length() < 2 ? ("0" + temp) : temp;
            str = str + temp;
        }
        return str;
    }

    //解析国信时间 5da00000H = 0101 1101   1010  00000000000000000000
    //010111   = 23    0110 = 6    10000= 16   00000 = 0
    public static String getTimeVFromByte(byte[] bit)
    {
        String str = "";
        String s1 = Integer.toHexString(bit[3]& 0xFF);
        String s2 = Integer.toHexString(bit[2]& 0xFF);
        String s3 = Integer.toHexString(bit[1]& 0xFF);
        String s4 = Integer.toHexString(bit[0]& 0xFF);
        s1 = s1.length() < 2 ? ("0" + s1) : s1;
        s2 = s2.length() < 2 ? ("0" + s2) : s2;
        s3 = s3.length() < 2 ? ("0" + s3) : s3;
        s4 = s4.length() < 2 ? ("0" + s4) : s4;
        str = s1 + s2 + s3 + s4;
        String str_1 = HexString2BinString(str);//转为2进制数
        if(str_1.length()<32){
            for (int i=32-(str_1.length()); i>0; i--){
                str_1 = "0" + str_1;
            }
        }
        str_1 = str_1.replace(" ","");
        String y_ = str_1.substring(0, 6);
        String m_ = str_1.substring(6, 10);
        String d_ = str_1.substring(10, 15);
        String h_ = str_1.substring(15, 20);
        String M_ = str_1.substring(20, 26);
        int y = Integer.parseInt(y_, 2);
        int m = Integer.parseInt(m_, 2);
        int d = Integer.parseInt(d_, 2);
        int M = Integer.parseInt(M_, 2);
        int h = Integer.parseInt(h_, 2);
        m_ = m < 10 ? ("0" + m) : (m + "");
        d_ = d < 10 ? ("0" + d) : (d + "");
        h_ = h < 10 ? ("0" + h) : h +"";
        M_ = M < 10 ? ("0" + M) : M+"";
        str = ""+ y + m_+ d_+ h_+ M_;

        return str;
    }
    /// <summary>
    /// //16转2方法
    /// </summary>
    /// <param name="hexString"></param>
    /// <returns></returns>
    static String HexString2BinString(String hexString)
    {
        int i = Integer.parseInt(hexString, 16);
        String binary = Integer.toBinaryString(i);
        return binary;

    }

    /**
     * 16进制转10进制
     * @param bytes
     * @return
     */
    public static int getIntFromByte16(byte[] bytes)
    {
        byte[] bit = new byte[4];
        String bit_s = "";
        for (int i= bytes.length -1 ; i>-1; i--)
        {
            bit_s += (Integer.toHexString(bytes[i]& 0xFF).length() == 1 ? "0" + Integer.toHexString(bytes[i]& 0xFF) :Integer.toHexString(bytes[i]& 0xFF));
        }

        int v = 0;
        if (bit.length == 4)
        {
            v = Integer.parseInt(bit_s, 16);

        }
        v = Integer.parseInt(bit_s, 16);
        return v;
    }

    /**
     * 两位不足 补零,eg->0x0c 0x02:1202
     * @param bit
     * @return
     */
    private static String getStringFromByte(byte[] bit)
    {
        String str = "";
        for (int i = 0; i < bit.length; i++)
        {
            String temp = (int)(bit[i]) +"";
            temp = temp.length() < 2 ? ("0" + temp) : temp;
            str = str + temp;
        }
        return str;
    }

    /**
     * 简洁写法 byte数组转成16进制字符串
     * @param bytes byte数组
     * @return 16进制字符串
     */
    public static String bytesToHexString(byte[] bytes) {
        StringBuilder builder = new StringBuilder();
        for (byte b : bytes) {
            builder.append(String.format("%02X", b));
        }
        return builder.toString();
    }

    /**
     *
     * @param date yyyymmddHHMM
     * @return
     */
    public static String getDateFromString(String date,Integer hoursToSubtract) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmm"); // 定义日期格式
        //Date date = sdf.parse(date); // 将字符串转换为日期对象
        Calendar calendar = Calendar.getInstance();
        // 将 Calendar 对象设置为当前时间
        calendar.setTime(sdf.parse(date));
        // 从当前时间中减去指定的小时数（这里假设要减去24小时）
        //int hoursToSubtract = -24;
        calendar.add(Calendar.HOUR_OF_DAY, -hoursToSubtract);

        // 获取新的时间
        return sdf.format(calendar.getTime());
    }
    /**
     *
     * @param date yyyymmddHHMM 距离零点的小时数
     * @return
     */
    public static Integer getDateFromZero(String date) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yymmddHHMM"); // 定义日期格式
        Calendar calendar = Calendar.getInstance();
        // 将 Calendar 对象设置为当前时间
        calendar.setTime(sdf.parse(date));
        // 获取新的时间
        return calendar.get(Calendar.HOUR_OF_DAY);
    }

    public static byte[] setBaseNumber(String baseNumber,String communicateAddress){
        byte[] bit = new byte[31];
        bit[0] = (byte)0xC0;//起始符
        bit[1] = (byte)0x47;//类型码
        byte[] add = new byte[6];
        add = getByte(communicateAddress);
        System.arraycopy(add, 0, bit, 2, 6);
        bit[8] = 0x03;
        bit[9] = 0x01;
        bit[10] = 0x00;
        bit[16] = 0x10;
        bit[17] = 0x0A;
        bit[19] = 0x13;
        bit[21] = 0x10;
        bit[22] = 0x13;
        bit[24] = 0x03;

        baseNumberInspection(baseNumber,bit);

        byte[] temp1 = new byte[bit.length - 3];
        System.arraycopy(bit, 1, temp1, 0, temp1.length);
        bit[29] = getTotalForByte(temp1);
        bit[30] = (byte)0xD0;//类型码
        return bit;
    }

    public static void baseNumberInspection(String baseNumber,byte[] bytes){
        // 去除小数点
        String replace = baseNumber.contains(".") ? baseNumber.replace(".", "") : baseNumber + "00";

        replace = replace.length() == 8 ? replace : replace + "0";

        // 将字符串转换为整数
        int number = Integer.parseInt(replace);

        // 转换为6位的十六进制字符串
        String hexString = String.format("%06X", number);

        // 将每两位十六进制字符倒序存入字节数组
        for (int i = 0; i < 3; i++) {
            // 读取 hexString 中的每两位字符
            bytes[28 - i] = (byte) Integer.parseInt(hexString.substring(i * 2, i * 2 + 2), 16);
        }
    }

}
